// 匹配路由 2 添加匹配 动态路由
import createRouteMap from './create-route-map';
import {createRoute} from './history/base'

export default function createMatcher(routes) {
  let {pathList, pathMap} = createRouteMap(routes)
  console.log(pathList, pathMap)
  function match(location) {
    let record = pathMap[location]
    return createRoute(record, {
      path: location
    })
  }
  function addRoutes(routes) {
    createRouteMap(routes, pathList, pathMap) // 添加
  }
  return {
    match,
    addRoutes
  }
}